<?php
/**
 * Created by PhpStorm.
 * User: User
 * Date: 2017/10/16
 * Time: 19:13
 */

class printer
{
    private static $_instance=null;
    private  function  __construct()
    {

    }
    static function getInstance()
    {
        if(is_null(self::$_instance))
        {
            self::$_instance=new self();
           printf("1.单例模式:");

        }
        return self::$_instance;
    }


}
$p1=printer::getInstance();

$p2=printer::getInstance();

Var_dump($p1);
echo "<br/>";
printf("2.单例模式:");
Var_dump($p2);
